package cn.web.management.service.general;

import cn.web.management.dao.impl.UpdateUserDaoImpl;
import cn.web.management.dao.inface.UpdateUserDao;
import cn.web.management.domain.Salary;

public class AdminUpdate {
    private UpdateUserDao updateUserDao = new UpdateUserDaoImpl();
    
    /**
     * @description: 管理员更新部分员工信息
     * @paramName: [employno, field, value]
     * @paramType: [java.lang.String, java.lang.String, java.lang.String]
     * @returnType: boolean
     */
    public boolean updatePersonalInform(String employno, String field, String value){
        return updateUserDao.updatePartPersonalInform(employno, field, value);
    }

    /**
     * @description: 删除员工信息，包括薪资信息和员工个人信息
     * @paramName: [employno]
     * @paramType: [java.lang.String]
     * @returnType: boolean
     */
    public boolean deletePersonalInform(String employno){
        int i = updateUserDao.deleteSalary(employno);
        boolean b = updateUserDao.deletePersonalInform(employno);
        return true;
    }

    public boolean entrySalary(Salary salary){
        int salary_number = 0;
        salary_number+=Integer.valueOf(salary.getBase_salary());
        salary_number+=Integer.valueOf(salary.getBonus());
        salary_number+=Integer.valueOf(salary.getSubsidies());
        salary_number+=Integer.valueOf(salary.getOvertime_salary());
        salary_number-=Integer.valueOf(salary.getLeave_late());
        salary_number-=Integer.valueOf(salary.getTax());
        salary.setSalary_number(salary_number+"");
        String[] split = salary.getPayoff_time().split("-");
        String s = "";
        for (int i = 0; i < salary.getEmployno().length(); i++) {
            if (Character.isDigit(salary.getEmployno().charAt(i)))
                s += salary.getEmployno().charAt(i);
        }
        salary.setPayroll("MLD"+split[0]+split[1]+split[2]+s);
        boolean b = updateUserDao.addPayroll(salary);
        return b;
    }
}
